﻿@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
@model DepartmentWork.Model.MonthlyViewModel
<link href="~/Assets/plugins/bootstrap-treeview/css/bootstrap-treeview.css" rel="stylesheet" />
<script src="~/Assets/plugins/bootstrap-treeview/js/bootstrap-treeview.js"></script>
<style>
   ul>.active {
       font-weight:bold
   }

</style>
<script>

    function DelWorkMonthly(monthlyId, proId)
    {
        if (!confirm("请确认是否删除该工作记录？"))
        {
            return false;
        }
        window.location.href = '@Url.Action("DelMonthly", "Monthly", new { area = "ProjectManageArea" })' + '?monthlyId=' + monthlyId + "&proId=" + proId;
    }

    function ShowParentXiangMu(index)
    {
        if ($("#treeview_XiangMu li[data-nodeid='XiangMu_" + index + "']").css('display') == 'block')
        {
            $("#treeview_XiangMu li[data-nodeid='XiangMu_" + index + "']").hide(300);
            $("#span_XiangMu_" + index).attr('class', 'icon expand-icon glyphicon glyphicon-plus');
        }
        else
        {
            $("#treeview_XiangMu li[data-nodeid='XiangMu_" + index + "']").show(300);
            $("#span_XiangMu_" + index).attr('class', 'icon expand-icon glyphicon glyphicon-minus');
        }
    }
</script>

<script>
    function ShowParentYunWei(index)
    {
        if ($("#treeview_YunWei li[data-nodeid='YunWei_" + index + "']").css('display') == 'block')
        {
            $("#treeview_YunWei li[data-nodeid='YunWei_" + index + "']").hide(300);
            $("#span_YunWei_" + index).attr('class', 'icon expand-icon glyphicon glyphicon-plus');
        }
        else
        {
            $("#treeview_YunWei li[data-nodeid='YunWei_" + index + "']").show(300);
            $("#span_YunWei_" + index).attr('class', 'icon expand-icon glyphicon glyphicon-minus');
        }
    }
</script>

<div class="page-header">
    <div class="pull-left">
        <ol class="breadcrumb visible-sm visible-md visible-lg">
            <li><a href="@Url.Action("Index", "Home", new { area = "" })"><i class="icon fa fa-home"></i>主页</a></li>
            <li><a href="@Url.Action("Index", "Project", new { area = "ProjectManageArea" })"><i class="fa fa-envelope"></i>项目模块</a></li>
            <li><a href="@Url.Action("Index", "Project", new { area = "ProjectManageArea", projectId = ViewBag.ProjectId })"><i class="fa fa-envelope"></i>项目详情</a></li>
            <li class="active"><a href="#"><i class="fa fa-envelope"></i>月报</a></li>
        </ol>
    </div>
</div>


@{
    if (ViewBag.flag == "CreateTrue")
    {
    <div class="alert alert-success">
        <button type="button" class="close" data-dismiss="alert">×</button>
        <strong>&emsp;月报添加成功！</strong>
    </div>
    }
    if (ViewBag.flag == "CreateFalse")
    {
    <div class="alert alert-danger">
        <button type="button" class="close" data-dismiss="alert">×</button>
        <strong>&emsp;月报添加失败！</strong> @ViewBag.Info
    </div>
    }
    if (ViewBag.flag == "ExecuteTrue")
    {
    <div class="alert alert-success">
        <button type="button" class="close" data-dismiss="alert">×</button>
        <strong>&emsp;月报生成成功！</strong>
    </div>
    }
    if (ViewBag.flag == "ExecuteTrue")
    {
    <div class="alert alert-danger">
        <button type="button" class="close" data-dismiss="alert">×</button>
        <strong>&emsp;月报生成失败！</strong> @ViewBag.Info
    </div>
    }

    if (ViewBag.flag == "DelTrue")
    {
    <div class="alert alert-success">
        <button type="button" class="close" data-dismiss="alert">×</button>
        <strong>&emsp;月报删除成功！</strong>
    </div>
    }

    if (ViewBag.flag == "DelFalse")
    {
    <div class="alert alert-danger">
        <button type="button" class="close" data-dismiss="alert">×</button>
        <strong>&emsp;月报删除失败！</strong> @ViewBag.Info
    </div>
    }
}


<div class="panel">
    <div class="panel-heading bk-bg-primary">
        <h6><i class="fa fa-table red"></i><span class="break"></span>@ViewBag.ProjectName 项目月报</h6>
        <div class="panel-actions">
            @*            @{
                if (ViewBag.IsAdmin)
                {
                    <a onclick="CreateMonthly()" class="bk-margin-5 btn btn-default  btn-sm" style="background-color: #ECEDF0">&nbsp;&nbsp;生成月报&nbsp;&nbsp;</a>
                   <a data-toggle="modal" data-target="#myModal" class="bk-margin-5 btn btn-default  btn-sm" style="background-color: #ECEDF0">&nbsp;&nbsp;上传月报&nbsp;&nbsp;</a>
                }
            }*@
        </div>
    </div>
    <div class="panel-body">

        <div class="tabs">
            <ul class="nav nav-tabs">
                <li class="active">
                    <a href="#edit" style="color:black" data-toggle="tab">月报查询</a>
                </li>
                <li class="">
                    <a style="color:black" href="@Url.Action("CreateMonthly")">月报生成</a>
                </li>
                <li class="">
                    <a href="#overview" style="color:black" data-toggle="tab">上传月报</a>
                </li>
            </ul>
            <div class="tab-content">

                <div id="edit" class="tab-pane active">

                    <div class="col-sm-12">
                        <label for="treeview"></label>
                        <div id="treeview" class="treeview">
                            <ul id="ul_user" class="list-group">
                                @*                <li class="list-group-item node-treeview" data-nodeid="0">
                                        <!-- 节点合并样式为 glyphicon-plus 展开样式为： glyphicon-minus-->
                                        <span class="icon expand-icon glyphicon glyphicon-plus"></span>
                                        <span class="icon node-icon"></span>
                                        软件科 一级节点 节点 合并
                                        <span class="badge">3 child elements</span>
                                    </li>*@

                                <!-- class中 加 ‘node-selected’ 代表 选中 ，选中后改变样式 style="color:#FFFFFF;background-color:#428bca;"-->
                                <li class="list-group-item node-treeview" onclick="ShowParent(1)">
                                    <span id="span_1" class="icon expand-icon glyphicon glyphicon-minus"></span>
                                    <span class="icon node-icon"></span>
                                    月报
                                    <span class="badge">文档数量：@ViewBag.MonthlyCount</span>
                                </li>
                                @{
                                    for (int i = 0; i < this.Model.FileList.Count(); i++)
                                    {
                                        var item = this.Model.FileList[i];
                                    <li class="list-group-item node-treeview" data-nodeid="1">
                                        <span class="indent"></span>
                                        <span class="icon"></span>
                                        <span class="icon node-icon"></span>
                                        @item.FILE_SHOWNAME
                                        <span class="badge">
                                            <a href="@Url.Content("~/Home/DownLoadFile?filePath=" + item.FILE_SAVENAME + "&type=Monthly&fileName=" + item.FILE_SAVENAME)">下载</a>
                                        </span>
                                        @{
                                        if (ViewBag.IsAdmin)
                                        {
                                            <span class="badge">
                                                <a  onclick="DelWorkMonthly('@item.FILE_ID','@item.CONTACT_ID')">删除</a>
                                            </span>
                                        }
                                        }
                                    </li>
                                    }
                                }

                            </ul>
                        </div>
                    </div>
                </div>

                <div id="overview" class="tab-pane ">
                    <div class="col-sm-12">
                        <form id="frm_UpLoadMonthly" method="POST" enctype="multipart/form-data" action="@Url.Action("CreateMonthly", "Monthly", new { area = "ProjectManageArea" })">
                            <div class="modal-body">
                                <div class="alert alert-danger" id="div_CheckUpLoadMonthlyMessage" style="display: none">
                                    <button type="button" class="close" data-dismiss="alert">×</button>
                                    <strong>
                                        <label id="lb_CheckUpLoadMonthlyMessage"></label>
                                    </strong>
                                </div>
                                <div class="row">
                                    <input type="hidden" name="hid_ProjectId" value="@ViewBag.ProjectId"/>
                                    <div class="form-group col-sm-4">
                                        <label for="select_year">选择年份：</label>
                                        <select id="select_year" name="select_year" class="form-control" >
                                            <option value="">请选择</option>
                                            <option value="2017">2017</option>
                                            <option value="2018">2018</option>
                                            <option value="2019">2019</option>
                                            <option value="2020">2020</option>
                                            <option value="2021">2021</option>
                                            <option value="2022">2022</option>
                                            <option value="2023">2023</option>
                                            <option value="2024">2024</option>
                                            <option value="2025">2025</option>
                                        </select>
                                    </div>

                                    <div class="form-group col-sm-4">
                                        <label for="select_month">选择月份：</label>
                                        <select id="select_month" name="select_month"  class="form-control">
                                            <option value="">请选择</option>
                                            <option value="1">1</option>
                                            <option value="2">2</option>
                                            <option value="3">3</option>
                                            <option value="4">4</option>
                                            <option value="5">5</option>
                                            <option value="6">6</option>
                                            <option value="7">7</option>
                                            <option value="8">8</option>
                                            <option value="9">9</option>
                                            <option value="10">10</option>
                                            <option value="11">11</option>
                                            <option value="12">12</option>
                                        </select>
                                    </div>

                                    <div class="form-group col-sm-4">
                                        <label for="tb_DocumentFile">文档：</label>
                                        <input  id="tb_DocumentFile" style="border-color: cornflowerblue;width: 100%" name="tb_MonthlyFileName" class="form-control" placeholder="文件展示名" type="file">
                                    </div>

                                </div>
                                <br />

                            </div>
                            <div class="modal-footer">
                                <input onclick=" CheckUpLoadMonthly()" type="button" class="btn btn-primary" value="上传" />
                            </div>
                        </form>
                    </div>
                </div>

            </div>
        </div>

    </div>
</div>
<script>
    function CheckUpLoadMonthly() {
        var msg = "";
        if ($("#frm_UpLoadMonthly #select_year").val()=="") {
            msg += "·月报年份不能为空 <br/>";
        }
        if ($("#frm_UpLoadMonthly #select_month").val() == "")
        {
            msg += "·月报月份不能为空 <br/>";
        }
        if ($("#frm_UpLoadMonthly #tb_DocumentFile").val() == "")
        {
            msg += "·月报文件不能为空 <br/>";
        }
        if (msg!="") {
            $("#div_CheckUpLoadMonthlyMessage").css("display", "block");
            $("#lb_CheckUpLoadMonthlyMessage").html(msg);
            return false;
        } else {
            $("#frm_UpLoadMonthly").submit();
        }
    }
</script>
